﻿using System.Diagnostics;
using System.Net;
using Windows.Dns;

namespace WPTestApp
{
    public partial class MainPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        protected async override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // create a DNS request
            var request = new Request();

            var domain = "builttoroam.com";
            var type = DnsType.MX;
            var dnsServer = IPAddress.Parse("203.0.178.191");

            // create a question for this domain and DNS CLASS
            request.AddQuestion(new Question(domain, type, DnsClass.IN));

            // send it to the DNS server and get the response
            //Response response = 

            var resp = await Resolver.Lookup(request, dnsServer);
            foreach (var answer in resp.Answers)
            {
                Debug.WriteLine("{0}", answer.Record);    
            }
            
        }
    }
}